<#assign module="driver"/>

<@override name="header">
</@override>
<@override name="body">
    <div class="tabbable tabs-left">
        <div class="row">
            <div class="col-xs-12 col-md-10">
                <div class="orders-navt">
                    <ul class="orders-nav">
                        <@shiro.hasPermission name='servicePersonal'>
                            <li style="width:90px;"><a href="${ctx}/driver/list">服务人员</a></li>
                        </@shiro.hasPermission>
                        <@shiro.hasPermission name='drivergrade'>
                            <li style="width:110px;"><a href="${ctx}/drivergrade/list">服务人员等级</a></li>
                        </@shiro.hasPermission>
                        <@shiro.hasPermission name='driverapply'>
                            <li><a href="${ctx}/driverapply/list">申请</a></li>
                        </@shiro.hasPermission>
                        <@shiro.hasPermission name='callLog'>
                            <li style="width:90px;"><a href="${ctx}/driver/recordlist">通话记录</a></li>
                        </@shiro.hasPermission>
                        <@shiro.hasPermission name='notice'>
                            <li class="orders-click"><a href="${ctx}/notice/list" class="orders-click-a">通知</a></li>
                        </@shiro.hasPermission>
                        <@shiro.hasPermission name='announcement'>
                            <li style="width:90px;"><a href="${ctx}/driver/announcementList">公告</a></li>
                        </@shiro.hasPermission>
                        <@shiro.hasPermission name='drivermoney'>
                            <li style="width:90px;"><a href="${ctx}/driver/drivermoney">批量操作</a></li>
                        </@shiro.hasPermission>
                        <@shiro.hasPermission name='drivermoney'>
                            <li style="width:110px;"><a href="${ctx}/driver/driverReward">服务人员奖励</a></li>
                        </@shiro.hasPermission>
                        <@shiro.hasPermission name='driverenchashment'>
                            <li style="width:100px;"><a href="${ctx}/driverenchashment/list">申请提现</a></li>
                            <li style="width:120px;"><a href="${ctx}/driverRebateenchashment/extendList">申请提取推广奖励</a></li>
                        </@shiro.hasPermission>
                        <@shiro.hasPermission name='driverloginrecord'>
                            <li style="width:90px;"><a href="${ctx}/driver/loginlist">登录日志</a></li>
                        </@shiro.hasPermission>
                    </ul>
                </div>
            </div>

            <div class="col-xs-1">
            </div>
            <div class="col-xs-12 col-md-2">
                <button id="add_button" class="pull-right buttoncss" style="display:none;"
                        onclick="window.location='${ctx}/notice/add';"><b>+</b>&nbsp;发布新通知
                </button>
            </div>
        </div>
    </div>



    <div class="tabta-content margin-top">
        <table class="table table-condensed table-striped">
            <tbody>
            <tr>
                <th style='min-width:500px;'>内容</th>
                <th style='min-width:150px;'>时间</th>
                <th style='min-width:120px;'>操作</th>
            </tr>
            <#if (page.content)?? >
                <#list page.content as data>
                    <tr class="tr-hui">
                        <td>${data.content?if_exists}</td>
                        <td>${data.created?string('yyyy/MM/dd HH:mm')}</td>
                        <td>
                            <@shiro.hasPermission name='noticedelete'>
                                <a href="javascript:;" data-value="${data.id}" class="btn-link deletethis">删除</a>
                            </@shiro.hasPermission>
                            <a href="${ctx}/notice/view/${data.id}" class="btn-link ">查看</a>
                        </td>
                    </tr>
                </#list>
            </#if>
            </tbody>
        </table>
        <#if page.totalElements??>
            <ul class="pagination pull-right pagination-sm">
                <li><a>共 ${page.totalElements} 条数据</a></li>
                <@pg.pager items=page.totalElements?number maxPageItems=20 export="currentPageNumber=pageNumber" url="${ctx}/notice/list">
                    <@pg.index>
                        <@pg.first>
                            <li><a href="${pageUrl}">&laquo;</a></li>
                        </@pg.first>
                        <@pg.prev>
                            <li><a href="${pageUrl}">&lsaquo;</a></li>
                        </@pg.prev>
                        <@pg.pages>
                            <#if currentPageNumber == pageNumber >
                                <li class="active"><a href="#">${pageNumber}</a></li>
                            <#else>
                                <li><a href="${pageUrl}">${pageNumber}</a></li>
                            </#if>
                        </@pg.pages>
                        <@pg.next>
                            <li><a href="${pageUrl}">&rsaquo;</a></li>
                        </@pg.next>
                        <@pg.last>
                            <li><a href="${pageUrl}">&raquo;</a></li>
                        </@pg.last>
                    </@pg.index>
                </@pg.pager>
            </ul>
        </#if>
    </div>

</@override>
<@override name="footer">
    <script type="text/javascript">
        var thisButton;

        function deleteNotice() {
            $.post('${ctx}/notice/delete', {'id': thisButton.attr("data-value")}, function (data) {
                if (data.success) {
                    thisButton.parent().parent().remove();
                    $.scojs_message('通知删除成功', $.scojs_message.TYPE_OK);
                } else {
                    $.scojs_message(data.message, $.scojs_message.TYPE_ERROR);
                }
            }, 'json');
        }

        $(document).ready(function () {
            $(".deletethis").click(function () {
                thisButton = $(this);
                var confirm = $.scojs_confirm({
                    content: "你真的要删除该通知吗？",
                    action: deleteNotice
                });
                confirm.show();
            });

            var add_sms = false;
            var add_app = false;
            <@shiro.hasPermission name='driversms'>
            add_sms = true;
            </@shiro.hasPermission>
            <@shiro.hasPermission name='driverappnotice'>
            add_app = true;
            </@shiro.hasPermission>
            if (add_sms || add_app) {
                $("#add_button").show();
            }
        });
    </script>
</@override>
<@extends name="../layout.ftl"/>